package MapDemo;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class TreeMapDemo {
    public static void main(String[] args) {
        TreeMap<String,String> map=new TreeMap<String,String>();
        //向集合中添加数据
        map.put("001","张三");
        map.put("009","张三");
        map.put("003","李四");
        map.put("007","张三");
        map.put("005","王二");
        map.put("005","田七");
        map.put("001","王二");
        //获得键值对对象
        Set<Map.Entry<String, String>> keyValues = map.entrySet();
        //迭代Set集合
        for (Iterator<Map.Entry<String, String>> it = keyValues.iterator(); it.hasNext();) {
            Map.Entry<String, String> keyValue =  it.next();
            //输出key和value
            System.out.println(keyValue.getKey()+"==="+keyValue.getValue());
        }
    }
}
